/**
 * 客服回复相关服务
 * @authors 杨兴洲（of2502）
 * @date    2017/3/29 19:32
 * @version 1.0
 */
/// <reference path="./weixin-custom-service.d.ts" />
import * as rp from "request-promise-native";

const HOST = 'https://api.weixin.qq.com/cgi-bin';

export default class WxCustomService {
    static sendMessage({access_token, message}: sendMsgParams): Promise<any> {
        return rp({
            method: 'POST',
            uri: `${HOST}/message/custom/send`,
            qs: {access_token},
            body: {...message},
            json: true
        })
            .then((data: any) => data.errcode ? Promise.reject(data) : data);
    }
}
